package com.tony.juc;

import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.ConcurrentSkipListSet;

/**
 * Created with IntelliJ IDEA.
 *
 * @Title: ConcurrentSkipListMapDemo001
 * @Auther: 皮蛋布丁
 * @Date: 2022/04/16/13:40
 * @Description: 跳表集合(不想使用红黑树的结构存储数据，最终就直接基于跳表的结构存储，既便于数据的查询，同时又可以在多线程并发更新下实现更新处理)
 */
public class ConcurrentSkipListMapDemo001 {

    public static void main(String[] args) {

        /*Set<String> all = new ConcurrentSkipListSet<>();
        for (int num = 0; num < 10; num++) {
            new Thread(()->{
                for (int i = 0; i < 10; i++) {
                    all.add("【" + Thread.currentThread().getName() + "】皮蛋布丁");
                    System.out.println(all);
                }
            },"集合操作线程_" + num).start();
        }*/

        Map<String,String> map = new ConcurrentSkipListMap<>();
        for (int num = 0; num < 10; num++) {
            new Thread(()->{
                for (int i = 0; i < 10; i++) {
                    map.put("【" + Thread.currentThread().getName() + "】i = " + i,"皮蛋布丁");
                    System.out.println(map);
                }
            },"集合操作线程_" + num).start();
        }

    }
}
